package Csp.Model;

//Binario
public class Constraint {
	//Matrice |domain(v1)| * |domain(v2)|: true coppia NON valida, false coppia valida
	//Mantengo solo il vincolo con l'ordinamento tra v1 < v2
	private boolean[][] matrix;
	private int v1;
	private int v2;
	
	public Constraint(int v1, int v2, boolean[][] matrix){
		
		if(v1 >= v2){
			throw new Error("V1 id must be < V2 id");
		}
		
		this.v1 = v1;
		this.v2 = v2;
		this.matrix = matrix;
	}
	
	public boolean[][] getMatrix() {
		return matrix;
	}
	
	public void setMatrix(boolean[][] matrix) {
		this.matrix = matrix;
	}
	
	public boolean isSatisfied(int id1, int value1, int id2, int value2){
		if(id1 < id2){
			return !matrix[value1][value2];
		}
		else{
			return !matrix[value2][value1];
		}
	}

	public int getV1() {
		return v1;
	}

	public void setV1(int v1) {
		this.v1 = v1;
	}

	public int getV2() {
		return v2;
	}

	public void setV2(int v2) {
		this.v2 = v2;
	}
	
}
